package com.though.utils.result;

public class RestResult {

	private int code;
	private String msg;
	private Object data;
	
	public RestResult() {
		
	}
	
	public RestResult(String msg) {
		this.code = ResultCode.ERROR.getCode();
		this.msg = msg;
	}
	
	public RestResult(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}
	
	public RestResult(Object data) {
		this.code = ResultCode.SUCCESS.getCode();
		this.msg = ResultCode.SUCCESS.getMsg();
		this.data = data;
	}
	
	public RestResult(int code, String msg, Object data) {
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	
	public static RestResult success() {
		return RestResult.success(null);
	}
	
	public static RestResult success(Object data) {
		return new RestResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMsg(), data);
	}
	
	public static RestResult error(String msg) {
		return RestResult.error(ResultCode.ERROR.getCode(), msg, null);
	}
	
	public static RestResult error(int code, String msg) {
		return RestResult.error(code, msg, null);
	}
	
	public static RestResult error(int code, String msg, Object data) {
		return new RestResult(code, msg, data);
	}
	
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public String getMsg() {
		return msg;
	}
	public void setMsg(String msg) {
		this.msg = msg;
	}
	public Object getData() {
		return data;
	}
	public void setData(Object data) {
		this.data = data;
	}
}
